package com.xxl.job.executor.service.impl;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.executor.dao.WebReportHistoryMapper;
import com.xxl.job.executor.model.WebReportHistory;
import com.xxl.job.executor.service.WebReportHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WebReportHistoryServiceImpl implements WebReportHistoryService {

    @Autowired
    private WebReportHistoryMapper webReportHistoryMapper;

    @Override
    public ReturnT<Integer> save(WebReportHistory webReportHistory) {
        int result = webReportHistoryMapper.save(webReportHistory);
        if(result > 0) {
            return new ReturnT<>(result);
        } else {
            return new ReturnT<>(ReturnT.FAIL_CODE, "保存失败");
        }
    }

    @Override
    public ReturnT<Integer> delete(int id) {
        int result = webReportHistoryMapper.delete(id);
        if(result > 0) {
            return new ReturnT<>(result);
        } else {
            return new ReturnT<>(ReturnT.FAIL_CODE, "删除失败");
        }
    }

    @Override
    public ReturnT<Integer> update(WebReportHistory webReportHistory) {
        int result = webReportHistoryMapper.update(webReportHistory);
        if(result > 0) {
            return new ReturnT<>(result);
        } else {
            return new ReturnT<>(ReturnT.FAIL_CODE, "更新失败");
        }
    }

    @Override
    public ReturnT<WebReportHistory> loadById(int id) {
        WebReportHistory result = webReportHistoryMapper.loadById(id);
        if(result != null) {
            return new ReturnT<>(result);
        } else {
            return new ReturnT<>(ReturnT.FAIL_CODE, "查询失败");
        }
    }
}
